package com.application.Tree;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Paint.Style;

public class FocusRect {
	private float x, y, w, h;
	private RectF focusRect;
	private Paint paint;
	private INode node;
	public FocusRect(INode node) {
		if (node != null) {
			this.node=node;
			this.x = node.getX();
			this.y = node.getY();
			this.w = node.getWidth();
			this.h = node.getHeigh();
			focusRect = new RectF(this.x - 2, this.y - 2, this.x + this.w + 2,
					this.y + this.h + 2);
			paint = new Paint();
			paint.setAntiAlias(true);
			paint.setStyle(Style.STROKE);
			paint.setStrokeWidth(1);
			paint.setColor(Color.RED);
			paint.setStrokeWidth(2);
		}
	}

	public void onDraw(Canvas canvas) {
		if(this.node!=null && this.node.showed)
			canvas.drawRoundRect(focusRect, 5, 5, paint);
	}
	public void moveAll(float moveX, float moveY) {
		this.x=this.x+moveX;
		this.y=this.y+moveY;
		focusRect = new RectF(this.x - 2, this.y - 2, this.x + this.w + 2,
				this.y + this.h + 2);
	}
}
